package com.itheima.day20.demo05;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.TreeSet;

public class demo08 {
    public static final String SOURCED = "./homework/src/com/itheima/day20/demo05/1.txt";
    public static final String DEST = "./homework/src/com/itheima/day20/demo05/2.txt";

    public static void main(String[] args) throws Exception {
        String s = null;
        TreeSet<Integer> ts = new TreeSet<>((e1, e2) -> e2.compareTo(e1));
        BufferedReader br = new BufferedReader(new FileReader(SOURCED));
        BufferedWriter bw = new BufferedWriter(new FileWriter(DEST));
        while ((s = br.readLine()) != null) {
            ts.add(Integer.parseInt(s));
        }
        br.close();
        for (Integer t : ts) {
            System.out.println(t);
            bw.write(t.toString());
            bw.newLine();
        }
        bw.flush();
        bw.close();
    }
}
